<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        var str = 'hello';

        function bytesLen(str) {
            var len = str.length;
            var count = len;
            for(var i = 0; i < len; i++){
                if(str.charCodeAt(i) > 255) {
                    count ++;
                }
            }
            return count;
        }

        console.log(bytesLen(str));



    </script>
</body>
</html>